//
//  OATableConfig.h
//  OASDK_Works
//
//  Created by ChenJie on 3/29/20.
//  Copyright © 2020 Mist. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "OASectionConfig.h"

@interface OATableConfig : NSObject

@property (nonatomic, weak) UITableView *tableView;

/* add section */
- (OASectionConfig *)addSection:(OASectionConfig *)section;
- (OASectionConfig *)addSectionWithName:(NSString *)sectionName;

/* get section */
- (OASectionConfig *)sectionAtIndex:(NSInteger)sectionIndex;
- (OASectionConfig *)sectionWithName:(NSString *)sectionName;

/* add cell for default section */
- (OACellConfig *)addCell:(OACellConfig *)cell;
- (OACellConfig *)addCellWithType:(NSString *)cellType viewModel:(id)viewModel;
- (OACellConfig *)addCellWithType:(NSString *)cellType staticHeight:(CGFloat)staticHeight viewModel:(id)viewModel;
- (OACellConfig *)addCellWithName:(NSString *)cellName type:(NSString *)cellType viewModel:(id)viewModel;

- (OACellConfig *)addCellWithName:(NSString *)cellName
                             type:(NSString *)cellType
                     staticHeight:(CGFloat)staticHeight
                        viewModel:(id)viewModel;

/* get cell */
- (OACellConfig *)cellAtIndexPath:(NSIndexPath *)indexPath;
- (OACellConfig *)cellWithSectionName:(NSString *)sectionName cellName:(NSString *)cellName;

/* get cell of default section */
- (OACellConfig *)cellAtIndex:(NSInteger)cellIndex;
- (OACellConfig *)cellWithName:(NSString *)cellName;

/* get cell viewModel */
- (id<OACellViewModelProtocol>)viewModelAtIndexPath:(NSIndexPath *)indexPath;
- (id<OACellViewModelProtocol>)viewModelWithSectionName:(NSString *)sectionName cellName:(NSString *)cellName;

/* get cell viewModel of default section */
- (id<OACellViewModelProtocol>)viewModelAtIndex:(NSInteger)cellIndex;
- (id<OACellViewModelProtocol>)viewModelWithName:(NSString *)cellName;

/*  */
- (OASectionConfig *)sectionOfCell:(OACellConfig *)cell;

/* delete section */
- (void)deleteSectionAtIndex:(NSInteger)sectionIndex;
- (void)deleteSectionWithName:(NSString *)sectionName;

/* delete cell */
- (void)removeAllCells;
- (void)deleteCellAtIndexPath:(NSIndexPath *)indexPath;
- (void)deleteCellWithSectionName:(NSString *)sectionName cellName:(NSString *)cellName;
- (void)deleteCell:(OACellConfig *)cell;

/* delete cell from default section */
- (void)deleteCellAtIndex:(NSInteger)cellIndex;
- (void)deleteCellWithName:(NSString *)cellName;

/* update cell */
- (void)updateCellAtIndexPath:(NSIndexPath *)indexPath;
- (void)updateCellAtIndexPath:(NSIndexPath *)indexPath withAnimation:(UITableViewRowAnimation)animation;

/* update section */
- (void)updateSection:(OASectionConfig *)section;
- (void)updateSection:(OASectionConfig *)section withAnimation:(UITableViewRowAnimation)animation;

#pragma mark - Delegate methods

/* UITableViewDataSource */
- (NSInteger)numberOfSectionsInTableView;
- (NSInteger)numberOfRowsInSection:(NSInteger)section;
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section;
- (NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section;

/* UITableViewDelegate */
- (CGFloat)heightForRowWithCellWidth:(CGFloat)cellWidth indexPath:(NSIndexPath *)indexPath;
- (void)didSelectRowAtIndexPath:(NSIndexPath *)indexPath;
- (CGFloat)heightForHeaderInSection:(NSInteger)section;
- (CGFloat)heightForFooterInSection:(NSInteger)section;

@end

